
import { request } from '@/utils/request';


import { BaseModel } from '@/api/common/baseModel'

export type ProfileDept = BaseModel
export type ProfileRole = BaseModel
export type ProfilePost = BaseModel
export interface SocialUser extends BaseModel {
  type: number
  openid: string
  token: string
  rawTokenInfo: string
  nickname: string
  avatar: string
  rawUserInfo: string
  code: string
  state: string
}
export interface ProfileVO extends BaseModel {
  username: string
  nickname: string
  dept: ProfileDept
  roles: ProfileRole[]
  posts: ProfilePost[]
  socialUsers: SocialUser[]
  email: string
  mobile: string
  gender: number
  avatar: string
  remark: string
  loginIp: string
  loginDate: Date
  createTime: Date
}

export interface UserProfileUpdateReqVO {
  nickname: string
  email: string
  mobile: string
  gender: number
}

// 查询用户个人信息
export const getUserProfile = () => {
  return request.get({ url: '/staff/web/userCenter/auth/user/getByToken.json' })
}

// 修改用户个人信息
export const update = (data: UserProfileUpdateReqVO) => {
  return request.put({ url: '/staff/web/userCenter/auth/user/update.json', data })
}

// 用户密码重置
export const updatePassword = (password: string, passwordNew: string) => {
  return request.put({
    url: '/staff/web/userCenter/auth/user/updatePwd.json',
    data: {
      password: password,
      passwordNew: passwordNew
    }
  })
}
